package com.lanhai.zhonglai.report;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
 

@EnableAsync 
@Service
public class StationStateMap {
	static Map<Integer,StationStateBean> stationMap= new ConcurrentHashMap<Integer,StationStateBean>( );

	
	public   void saveState (int dotno,String cmd)
	{
		try {
			StationStateBean ab=new StationStateBean();
			ab.setCmd(cmd);
		  	ab.setDotno(dotno); 
			stationMap.put(dotno, ab);
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	
 
	
	public   synchronized List<StationStateBean> getAll(){
		List<StationStateBean> re=new ArrayList<StationStateBean>(); 
		for(Entry<Integer,StationStateBean> entry: stationMap.entrySet()) {
			StationStateBean tmp=entry.getValue();
			StationStateBean ab=new StationStateBean();
			ab.setCmd(tmp.getCmd());
			ab.setDotno(tmp.getDotno());
		    re.add(ab);
		} 
		return re;
	}
}
